package com.xyd.servlet;

import com.xyd.entity.Admin;
import com.xyd.service.AdminService;
import com.xyd.service.impl.AdminServletImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 86186
 */
@WebServlet("/AdminServlet")
public class AdminServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String eaName=request.getParameter("eaName");
        String eaPassword=request.getParameter("eaPassword");

        AdminService adminService=new AdminServletImpl();
        Admin admin=adminService.LoginAdmin(eaName,eaPassword);

        PrintWriter out=response.getWriter();

        if (admin !=null){
            request.getSession().setAttribute("admin",admin);
            request.getRequestDispatcher("../manage/index.html");
            out.print(admin);
        }
        else {
            out.print("");
        }


    }
}
